#ifndef MODBUSPROTOCOL_H
#define MODBUSPROTOCOL_H

#include <QObject>
#include "Protocol/BaseProtocol.h"
#include "File/Xml/ModbusListXml.h"

class ModbusProtocol : public BaseProtocol
{
    Q_OBJECT
public:
    explicit ModbusProtocol(QObject *parent = 0);
    QList<Package> parseData(QByteArray data);
    QByteArray generateData(Package package);
    QByteArray getmodbusData(quint8 deviceAddr,quint8 FunctionCode,quint16 registerStartAddress);
    enum FunctionCode
    {

        ReadCoilRegister         = 0X01,
        ReadDiscreteCoilRegister = 0X02,
        ReadHoldRegister         = 0X03,
        ReadInputRegister        = 0X04,
        WriteSignalCoilRegister  = 0X05,
        WriteSignalHoldRegister  = 0X06,
        WriteMultCoilRegister    = 0X0F,
        WriteMultHoldRegister    = 0X10
    };

private:

    enum CheckSteps
    {
        CHECK_HEAD,
        CHECK_FUNCTION,
        CHECK_LENGTH,
        CHECK_BODY,
        CHECK_CHECKCODE,
    };
    QList<quint16> m_deviceAddressList;
    QList<quint8>  m_readFunctionCodeList;
    QList<quint8>  m_writeFunctionCodeList;

};

#endif // MODBUSPROTOCOL_H
